#!coding=utf-8
'''
Created on 2015-12-14

@author: Administrator
'''
from django.contrib import admin
from nachuan.models import Company, Company_fee ,Company_admin
from django.core.checks.messages import Error
    
class Company_type(admin.ModelAdmin):
    list_display=('name','manager')
#     list_filter=()
#     search_fields=()

class Company_fee_type(admin.ModelAdmin):
    list_display=('get_company_name','feename','feecount','feedate_end')
    list_filter=('feedate_end',)
    
    def get_company_name(self, obj):  
        return obj.company.name  
    get_company_name.short_description = '公司名称'
#     search_fields=()
class Company_admin_type(admin.ModelAdmin):
    list_display=('companyname','get_company_name','adminsts','wx_id')
    list_filter=('adminsts',)
#     search_fields=()
    def get_company_name(self, obj):
        try:
            if obj.company is None:
                return "" 
            else:
                return obj.company.name 
        except Error:
            return ""
    get_company_name.short_description = '公司名称'
    
    
admin.site.register(Company,Company_type)
admin.site.register(Company_fee,Company_fee_type)
admin.site.register(Company_admin,Company_admin_type)

